package aaa.brush.controller;

import aaa.brush.domain.BruOnlineBrushRecord;
import aaa.brush.domain.QuestionDTO;
import aaa.brush.service.IQuestionService;
import aaa.common.core.controller.BaseController;
import aaa.common.core.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/brush")
public class QuestionController extends BaseController {

    @Autowired
    private IQuestionService questionService;
    @PreAuthorize("@ss.hasPermi('brush:online:list')")
    @GetMapping("/next")
    public ResponseEntity<QuestionDTO> getNowQuestion(@RequestParam int userId, @RequestParam String questionType) {
        QuestionDTO questionDTO = questionService.getNextQuestion(userId, questionType);
        return ResponseEntity.ok(questionDTO);
    }

    @PreAuthorize("@ss.hasPermi('brush:online:list')")
    @PostMapping("/submit")
    public AjaxResult submit(@RequestBody BruOnlineBrushRecord record)
    {
        return toAjax(questionService.submit(record));
    }


}